<?php
/**
 * Punny - The most easy-to-use PHP MVC framework
 * 
 * Copyright (c) 2010  
 *
 * @author email :lx.xin@qq.com
 */
 class BaseController extends Zend_Controller_Action{
	function init(){
		$this->registry = Zend_Registry::getInstance();
        $this->view = $this->registry['view'];
        $this->view->baseUrl = $this->_request->getBaseUrl();
		$this->view->setScriptPath('./application/views/scripts/default/');
		$this->view->sitename = $this->registry['sitename'];
		$this->view->keywords = $this->registry['keywords'];
	}

	/*
	 *获取左侧日志分类
	 */
	 function side_class(){
		$s_c=new Classes();
		$row=$s_c->getClasses();
		return $row;
	 }

	 /*
	  *获取最新评论
	  *前5条
	  */
	  function side_comment(){
		$s_c=new Comment();
		$arr=$s_c->getComment();
		return $arr;
	  }

	  /*
	   *获得最新日志
	   *前5篇
	   */
	   function side_blog(){
			$s_b=new Blog();
			$data=$s_b->getBlog();
			return $data;
	   }

	   /*
	    *获得友情链接
		*/
		function side_link(){
			$s_l=new Link();
			$row=$s_l->getLink();
			return $row;
		}
		/*
		 *右侧所有日志
		 */
		 function r_blog(){
			$r_b=new Blog();
			$data=$r_b->getBlogList();
			return $data;
		 }
		 /*
		  *热门日志
		  */
		  function side_hot(){
			$s_h=new Blog();
			$data=$s_h->fetchAll('ishidden=0','commnums DESC',5)->toArray();
			$array=array();
			foreach($data as $key=>$value){
				$array[$key]['id']=$value['id'];
				$array[$key]['posttime']=$value['posttime'];
				$array[$key]['title']=$value['title'];
			}
			return $array;			
		  }
		/*
		 *点击排行
		 */
		 function side_hit(){
			$s_hit=new Blog();
			$data=$s_hit->fetchAll('ishidden=0','viewnums Desc',5)->toArray();
			$array=array();
			foreach($data as $key=>$value){
				$array[$key]['id']=$value['id'];
				$array[$key]['posttime']=$value['posttime'];
				$array[$key]['title']=$value['title'];
			}
			return $array;	
		 }
		 /*
		  *获取tag
		  */
		  function side_tag(){
			$tag=new Tag();
		  	$arr=$tag->getTag();
			$data=array();
			foreach ($arr as $key=>$val){
				$data[$key]['blognum']=$val['blognum'];
				$data[$key]['name']=$val['name'];
			}
			return $data;
		  }
		
 }
 ?>